<?php
class EWysiwyg {
	
	public static function show ($object, $model, $field, $value = NULL) {
		switch(Yii::app()->params['wysiwyg']){
			case 'ckeditor': self::ckeditor ($object, $model, $field, $value); break;
			case 'imperavi': self::imperavi ($object, $model, $field, $value); break;
			default: self::ckeditor ($object, $model, $field, $value); break;
		}
	}
	
	private static function ckeditor ($object, $model, $field, $value) {
		$object->widget('application.extensions.ckeditor.ECKEditor', array(
	        'model'=>$model,
	        'attribute'=>$field,
			'defValue'=>$value,
	        'language'=>'ru',
			'toolbar'=>array(
				array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
				array( 'Image', 'Link', 'Unlink', 'Anchor' ) ,
			),
			'options'=>array(
				'filebrowserBrowseUrl'=>CHtml::normalizeUrl(array('site/browse')),
			),
		));
	}
	
	private static function imperavi ($object, $model, $field, $value) {
		$object->widget('ext.imperavi-redactor-widget.ImperaviRedactorWidget',array(
        	'model'=>$model,
			'attribute'=>$field,
        ));
	}
}
?>